package com.itdev.matcherapp.android.gtalkclient;

import android.content.Context;
import android.media.MediaPlayer;
import android.media.MediaPlayer.OnCompletionListener;

import com.itdev.matcherapp.android.R;



public class SoundEffectPlayer implements OnCompletionListener {

	private MediaPlayer mp;
	private Context context;

	public SoundEffectPlayer(Context context) {
		super();
		this.context = context;
	}

	public void playTong() {
		try {
			mp = new MediaPlayer();
			mp = MediaPlayer.create(context, R.raw.tong);
			mp.setOnCompletionListener(this);
			//mp.setDataSource("/sdcard/Warning.wav");
			mp.prepareAsync();
			mp.start();
		} catch (IllegalArgumentException e) {
			if(mp!=null){
				mp.stop();
				mp.release();
			}
		}
	}

	public void onCompletion(MediaPlayer player) {
		// TODO Auto-generated method stub
		if (player != null) {
			player.stop();
			player.release();
		}
	}

}
